package com.benbi.shequapi.controller;

import com.benbi.shequapi.service.RecordService;
import com.benbi.shequapi.service.ReportService;
import com.benbi.shequapi.utils.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@RestController
@RequestMapping("/record")
public class RecordController {
    @Resource
    RecordService recordService;

    @RequestMapping("/getRecordStatis")
    public Result getRecordList(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date d) {
        return recordService.getRecordStatis(d);
    }

    @RequestMapping("/getRecordSignin")
    public Result getRecordSign(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date d) {
        return recordService.getRecordSignin(d);
    }

    @RequestMapping("/getRecordAccess")
    public Result getRecordAccess(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date d) {
        return recordService.getRecordAccess(d);
    }

    @RequestMapping("/getRecordTotal")
    public Result getRecordTotal(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date d) {
        return recordService.getRecordTotal(d);
    }

    @RequestMapping("/getRecordWarn")
    public Result getRecordWarn(@RequestParam("date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date d) {
        return recordService.getRecordWarn(d);
    }



    @RequestMapping("/addRecord")
    public Result addRecord(
            @RequestParam("r_pid") int r_pid,
            @RequestParam("recorder_id") int recorder_pid,
            @RequestParam("form") int form,
            @RequestParam("temp") float temp,
            @RequestParam("form_addr") String formAddr,
            @RequestParam("business") String business) {
        return recordService.addRecord(r_pid,recorder_pid,form,temp,formAddr,business);
    }
}